const moment = require('moment');
module.exports = app => {
  const {STRING, INTEGER, DATE, BIGINT} = app.Sequelize;
  
  const VisitLog = app.model.define('visitLog', {
    id: {
      type: BIGINT,
      primaryKey: true,
      autoIncrement: true,
    },
    year: INTEGER,
    month: INTEGER,
    create_time: {
      type: DATE,
      get() {
        return moment(this.getDataValue('create_time')).format('YYYY-MM-DD HH:mm:ss');
      }
    },
    user_id: BIGINT,
    visit_url: STRING(100),
  }, {
    tableName: 'hy_visit_log',
    timestamps: false,
  });

  return VisitLog;
};
